using System.Collections.Generic;
using System.Linq;
using mebc.tests.toDictionary;
using NUnit.Framework;

namespace mebc.tests.parts
{
    [TestFixture]
    public class demo_ToDictionary_Parts
    {
        [Test]
        public void Run()
        {
            var split = new FuncPart<string, IEnumerable<string>>(config => config.Split(';'));
            var trans = new Transform_assignments_into_KV();
            var build = new Build_dictionary();

            Dictionary<string, string> dict = null;
            split.OutputPipe += trans.InputPipe;
            trans.OutputPipe += build.InputPipe;
            build.OutputPipe += _ => dict = (Dictionary<string,string>)_.Value;

            split.InputPipe(new Message<string> {Value = "a=1;b=2"});

            Assert.AreEqual(new Dictionary<string, string> {{"a", "1"}, {"b", "2"}}, dict);
        }
    }
}